

package lab01;

import java.util.Scanner;

    public class Test12 {

        public static void main(String[] args) {

            System.out.println("请输入一个数（1-9999）：");

            Scanner sc = new Scanner(System.in);
            int num = sc.nextInt();
            int single = num % 10;
            int decade = num / 10 % 10;
            int hundred = num / 100 % 10;
            int thousand = num / 1000;

            if (num / 1000 >= 1) {
                System.out.println("这个数为四位数");
                if (single == thousand && decade == hundred) {
                    System.out.println("这个数是回文数：" + num);
                } else {
                    System.out.println("这个数不是回文数：" + num);
                }
            } else if (num / 100 >= 1) {
                System.out.println("这个数为三位数");
                if (single == hundred) {
                    System.out.println("这个数是回文数：" + num);
                } else {
                    System.out.println("这个数不是回文数：" + num);
                }
            } else if (num / 10 >= 1) {
                System.out.println("这个数为两位数");
                if (single == decade) {
                    System.out.println("这个数是回文数：" + num);
                } else {
                    System.out.println("这个数不是回文数：" + num);
                }
            } else {
                System.out.println("这个数为一位数");
                System.out.println("这个数不是回文数：" + num);
            }
        }
    }





